import React, { Component } from 'react'

export default function withFar(WrappedComponent) {
  return class Far extends Component {
    state = {
      username: '',
      password: '',
      repassword: '',
    }

    handleChange = (name) => {
      return (e) => {
        this.setState({
          [name]: e.target.value.trim(),
        })
      }
    }
    render() {
      const { username, password, repassword } = this.state
      return (
        <WrappedComponent
          username={username}
          password={password}
          repassword={repassword}
          handleChange={this.handleChange}
        ></WrappedComponent>
      )
    }
  }
}
